package com.hyzx.qbasic.admin.common.util;

import org.apache.shiro.crypto.hash.SimpleHash;
import org.apache.shiro.util.ByteSource;

/**
 * Created by 黄江华 on 2017/9/20
 *
 * 密码加密器
 */

public class PasswordEncryptor {
    private static final int ITERATIONS = 2;//散列的次数，比如散列两次，相当于 md5(md5(""));

    private static final String ALGORITHM_NAME = "md5";//散列算法:这里使用MD5算法;

    public static String encrypt(String password, String salt) {
        String passwordEncrypted = new SimpleHash(ALGORITHM_NAME, password, ByteSource.Util.bytes(salt), ITERATIONS).toHex();
        return passwordEncrypted;
    }
}
